package cn.xiaoxiang.org.dto;

import cn.xiaoxiang.org.domain.Employee;
import cn.xiaoxiang.org.domain.Shop;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import java.util.Date;

@Data
public class ShopSettlementDto {
    @NotBlank(message = "店铺名称不能为空")
    private String name;
    @NotBlank(message = "电话不能为空")
    private String tel;
    @NotBlank(message = "地址不能为空")
    private String address;
    private String logo;

     @Valid
    private Employee admin;
     public Shop getShop(){
        return Shop.builder()
                .name(this.getName())
                .tel(this.getTel())
                .address(this.getAddress())
                .logo(this.getLogo())
                .registerTime(new Date())
                .state(0)
                .build();

     }

     public Employee getEmp(){
         Employee employee = new Employee();
         BeanUtils.copyProperties(admin,employee);
         employee.setAge(20);
         employee.setState(1);
         return employee;
     }
}

